package com.ihrm.domain.system.response;

import com.ihrm.domain.system.Permission;
import com.ihrm.domain.system.Role;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


@Setter
@Getter
public class RoleResult implements Serializable {

    private String id;
    
    /**
     * 角色名
     */
    private String name;
    
    /**
     * 说明
     */
    private String description;
    
    /**
     * 企业id
     */
    private String companyId;
    
    private List<String> permIds = new ArrayList<>();
    
    public RoleResult(Role role){
        BeanUtils.copyProperties(role,this);
        for(Permission perm:role.getPermissions()){
            this.permIds.add(perm.getId());
        }
    }
    
}
